#include  <cstdio>
#include  <algorithm>
#include  <functional>
#include  <cstring>
#include  <iostream>
using namespace std;

int n,a[100],flag[100];

bool dfs(int start, int remain, int times,int num)
{
	int i = start;
	for( ; i < n ; ++i)
	{
		if(flag[i] == 0 && a[i] <= remain)
		{
			if(remain==num&&i>0&&flag[i-1]==0) //剪枝1
				return false;
			flag[i] = 1;
			int left = remain - a[i];
			if(left == 0)
			{
				times--;
				if(times == 0)
					return true;
				else
					if( dfs(0,num,times,num))
						return true;
					else
					{
						flag[i] = 0;
						return false;	//剪枝2
					}
			}
			else
				if(dfs(i+1,left,times,num))
					return true;
				else
				{
					flag[i] = 0;
					while(i < n-1 && a[i+1] == a[i]) i++; //剪枝3
					continue;
				}
		}
	}
	return false;
	
}

int main(int argc, char *argv[])
{
	while( scanf("%d",&n) && n != 0 )
	{
		int sum = 0;
		for( int i = 0 ; i < n ; ++i )
		{
			scanf("%d",&a[i]);
			sum += a[i];
		}
		
		sort(a,a+n,greater<int>());
		for( int i = a[0]; i <= sum  ; ++i )
		{
			if(sum%i != 0)
				continue;

			memset(flag,0,100*sizeof(int));
			int c = 0;
			
			if(dfs(0,i,sum/i,i))
			{
				printf("%d\n",i);
				break;
			}
		}
		
	}
}
